import org.kwis.msp.lcdui.Display;
import org.kwis.msp.lcdui.Jlet;
import org.kwis.msp.lwc.ActionListener;
import org.kwis.msp.lwc.ButtonComponent;
import org.kwis.msp.lwc.Component;
import org.kwis.msp.lwc.FormComponent;
import org.kwis.msp.lwc.ProgressComponent;
import org.kwis.msp.lwc.ShellComponent;

/** ProgressComponent 테스트 프로그램
 *  OK 버튼을 누를때 마다 count 값이 1씩 증가하면서
 *  ProgressComponent에 최대값(10)에 비해 어느정도 진행되고 있는지 보여준다.
 * ProgressTest.java 
 */
public class ProgressComponentEx1 extends Jlet implements ActionListener {
	private int countStep = 0;
	ButtonComponent button;
	ProgressComponent progress;

	protected void startApp(String[] arg0) {
		ShellComponent shell = new ShellComponent();
		progress= new ProgressComponent(false, 10);
		progress.setStep(2);
		progress.setMargin(20,20);

		FormComponent form = new FormComponent();
		button = new ButtonComponent("CountStep : 0", null);
		button.setActionListener( this, null);
		form.addComponent( button );
		form.addComponent( progress );
		shell.setTitle("   Progress ");
		shell.setWorkComponent( form );
		shell.show();
	}

	protected void destroyApp(boolean arg0) {
	}

	public void action(Component src, Object arg) {
		countStep++;
		if(countStep>10) countStep = 0;
		button.setString("CountStep : "+countStep);
		progress.setValue( countStep );
	}
}
